package org.grottarossa.query.docs;

import org.apache.commons.beanutils.BeanComparator;
import org.apache.solr.common.SolrInputDocument;
import org.springframework.beans.BeanUtils;

public abstract class SolrMainObject extends SolrInputDocument
{
	protected BeanComparator comparator = new BeanComparator();
	
	public boolean compare(Object obj)
	{
		return (comparator.compare(this, obj) == 0);
	}
	
	public Object cloneObj(Class<?> type)
	{ 
		Object obj = BeanUtils.instantiateClass(type);	
		BeanUtils.copyProperties(this, obj, type );		
		return obj;
	}
	
	public void update(Object obj,Class<?> type)
	{
		BeanUtils.copyProperties(obj, this, type);		
	}
	
	public abstract void update(Object obj);
	public abstract Object cloneObj();
	
	public BeanComparator getComparator() {
		return comparator;
	}
	public void setComparator(BeanComparator comparator) {
		this.comparator = comparator;
	}
	
	
	

}
